home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 July: Mac OS SDK / Dev.CD Jul 99 SDK2.toast / Development Kits / Hardware / Mac OS USB DDK / Examples / USBSampleStorageDriver / SampleStorageDriver.h < prev    next >
Encoding:
C/C++ Source or Header  |  1999-01-12  |  4.1 KB  |  162 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        SampleStorageDriver.h
  3.  
  4.     Contains:    All definitions used by the Sample Storage Driver
  5.  
  6.     Version:    1.1
  7.  
  8.     Copyright:    © 1998-1999 by Apple Computer, Inc., all rights reserved.
  9.  
  10.     File Ownership:
  11.  
  12.         DRI:                Craig Keithley
  13.  
  14.         Other Contact:        xxx put other contact here xxx
  15.  
  16.         Technology:            USB Drivers
  17.  
  18.     Writers:
  19.  
  20.         (CJK)    Craig Keithley
  21.  
  22.     Change History (most recent first):
  23.  
  24.       <USB2>     1/11/99    CJK        update to use sources from 1.1f3 DDK
  25. */
  26.  
  27.  
  28. #ifndef __SAMPLESTORAGEDRIVER__
  29. #define __SAMPLESTORAGEDRIVER__
  30.  
  31. #include <USB.h>
  32. #include "SampleStorageDriverAPI.h"
  33.  
  34.  
  35. #if DEBUG
  36. #define IF_DEBUG(x)    x
  37. #else
  38. #define IF_DEBUG(x)
  39. #endif
  40.  
  41. #define kStrStorageClass    "\pStorageClass: "
  42.  
  43. #define kStorageRetryCount    5
  44. #define kMaxTransitions        1
  45. #define kIntDataSize        8
  46. #define kStatusSize            2        // USB Status
  47. #define kUSBMaxBulkTransfer    0x200000        // Max transfer is 2MB
  48.  
  49. // These states are used by StorageDeviceInitiateConfiguration
  50. enum driverConfigStates
  51. {
  52.     kUndefined =                0,
  53.     
  54.     kSetConfig,
  55.     kGetFullConfiguration,
  56.     kFindStorageInterface,
  57.     kStorageConfigureInterface,
  58.     
  59.     kNewInterfaceRef,
  60.     kStorageFindInterruptPipe,
  61.     kStorageFindBulkInPipe,
  62.     kStorageFindBulkOutPipe,
  63.     kStorageReadInterrupt,
  64.     
  65.     kStorageExecuteCommand,                    // Begin execution of user command
  66.     kStorageExecuteCommandCompletion,        // Complete the user command
  67.     kStorageBulkIOComplete,                    // Complete the bulk read
  68.     kStorageGetStatus,                        // Complete the GetStatus request
  69.     kStorageGetStatusBulkRead,                // Get the status data
  70.     
  71.     kNilCompletion,
  72.     
  73.     kReturnFromDriver =         0x1000,
  74.     kRetryTransaction =         0x2000,
  75.     kAsyncTransaction =         0x4000,
  76.     kCompletionPending =         0x8000
  77. };
  78.  
  79. // Structure for the global PB's
  80. struct StorageClassTransactionPB {
  81.     USBPB                usbPB;
  82.     UInt8                cdb[kCDBSize];
  83.     UInt32                        currentState;
  84.     Boolean                        busy;
  85.     UInt32                        flags;                // Flags from StorageClassRequest pb
  86.     StorageExecuteCommandPBPtr    userPBPtr;
  87. };
  88. typedef struct StorageClassTransactionPB    StorageClassTransactionPB;
  89. typedef    StorageClassTransactionPB             *StorageClassTransactionPBPtr;
  90.  
  91.  
  92. struct StorageClassInfo {
  93.     USBPB                             usbPB;                    // Configuration block
  94.     
  95.     // Device info
  96.     UInt8                            firmwareVersion[2];
  97.     
  98.     // Interrupt pipe
  99.     USBPipeRef                         interruptPipeRef;        // USB pipe reference
  100.     UInt8                            interruptReport[kIntDataSize];
  101.     
  102.     //    mandatory bulk in pipe
  103.     USBPipeRef                         readPipeRef;            // USB pipe reference
  104.     
  105.     //    mandatory bulk out pipe
  106.     USBPipeRef                         writePipeRef;            // USB pipe reference
  107.  
  108.     //    device: configuration and interface details
  109.     USBDeviceRef                    interfaceRef;            // USB device reference
  110.     USBDeviceRef                    deviceRef;                // USB device reference
  111.     USBConfigurationDescriptorPtr     pFullConfigDescriptor;
  112.     USBConfigurationDescriptor        partialConfigDescriptor;
  113.     
  114.     USBInterfaceDescriptor            interfaceDescriptors[32];
  115.     USBInterfaceRef                    interfaceRefArray[32];
  116.     USBRqIndex                        interfaceCount;
  117.     USBRqIndex                        interfaceIndex;
  118.     
  119.     UInt32                            interfaceNumber;
  120.  
  121.     USBDeviceDescriptor             deviceDescriptor;        // copy for local reference
  122.     USBInterfaceDescriptorPtr        pInterfaceDescriptor;    // copy for local reference
  123.  
  124.     //    class driver async transactions
  125.     SInt32                            transDepth;                // don't nest transactions
  126.     SInt32                             retryCount;                // automatically retry transactions
  127.     UInt32                            currentState;            // State machine state
  128. };
  129. typedef struct StorageClassInfo    StorageClassInfo;
  130. typedef    StorageClassInfo         *StorageClassInfoPtr;
  131.  
  132.  
  133. struct StorageClassStatusPB {
  134.     USBPB                usbPB;
  135.     Boolean                busy;
  136.     StorageStatusPBPtr    userPBPtr;
  137.     UInt8                status[kStatusSize];
  138. };
  139. typedef struct StorageClassStatusPB    StorageClassStatusPB;
  140. typedef    StorageClassStatusPB         *StorageClassStatusPBPtr;
  141.  
  142.  
  143. struct StorageClassControlPB {
  144.     USBPB                usbPB;
  145.     Boolean                busy;
  146.     StorageControlPBPtr    userPBPtr;
  147. };
  148. typedef struct StorageClassControlPB    StorageClassControlPB;
  149. typedef    StorageClassControlPB             *StorageClassControlPBPtr;
  150.  
  151.  
  152. // Function protoypes
  153. extern OSStatus    StorageClassDriverInitialize(void);
  154.  
  155. extern OSStatus StorageClassDriverControl(UInt32 theControlSelector, void *theControlData);
  156.  
  157. extern OSStatus StorageClassDriverStatus(UInt32 theInfoSelector, void *theInfo);
  158.  
  159. extern OSStatus StorageClassDriverExecuteCommand(StorageExecuteCommandPBPtr storageExecuteCommandPBPtr);
  160.  
  161.  
  162. #endif /* __SAMPLESTORAGEDRIVER__ */